#define PI 3.1415
#define lightx 0.5
#define lighty 0.5
#define Threshold 0.1

precision highp float;

uniform sampler2D texture;
uniform float width;

void main(void)
{
	vec2 uv = gl_TexCoord[0].xy;
	vec2 uvL = vec2(((uv.x * width - 0.5) * 2 + 0.5) / width, uv.y);
	vec2 uvR = vec2((uvL.x * width + 1) / width, uv.y);

	vec2 colorL = texture2D(texture, uvL).rg;
	vec2 colorR = texture2D(texture, uvR).rg;

	vec2 result = vec2(min(colorL.x, colorR.x), min(colorL.y, colorR.y));

	gl_FragColor = vec4(result.x, result.y, 0., 1.);
}

//void main(void)
//{
//	vec2 uv = gl_TexCoord[0].xy;
//	vec2 color = texture2D(texture, uv).rg;
//	vec2 colorR = texture2D(texture, uv + vec2(width, 0.)).rg;
//	vec2 result = min(color, colorR);
//	//if (uv.x > width) gl_FragColor = vec4(1.);
//	//else 
//	gl_FragColor = vec4(result, 0., 1.);
//}